package com.sands.widget;

import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;

import com.sands.R;


/**
 * Created by Administrator on 2017/8/16.
 */

public class BaseDialogWindow extends Dialog {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //设置参数
        initConfig();
    }

    public BaseDialogWindow(Context context) {
        super(context, R.style.Default_Dialog_Theme);
    }

    private void initConfig() {
        //设置背景为透明
        getWindow().setBackgroundDrawable(new ColorDrawable(0));
        //设置布局
        //  getWindow().setContentView(owner_layout);
        //触摸设置
        setCanceledOnTouchOutside(true);
        //设置动画
        getWindow().setWindowAnimations(R.style.DefaultAnim);

		/*
* 将对话框的大小按屏幕大小的百分比设置
*/
//        Window window = getWindow();
//        WindowManager m = ((Activity) context).getWindowManager();
//        Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
//        WindowManager.LayoutParams p = window.getAttributes(); // 获取对话框当前的参数值
//        p.height = (int) (d.getHeight() * 0.6); // 高度设置为屏幕的0.6
//        p.width = (int) (d.getWidth() * 0.95); // 宽度设置为屏幕的0.95
//        window.setAttributes(p);

    }


}
